package com.redis.serialize;

import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.SerializationException;

/**
 * @Author hewei
 * @Description Redis String类型初始化 序列/反序列类
 * @Date 18:01 2021/5/11
 **/
public class EntityRedisSerializer  implements RedisSerializer<Object> {

    @Override
    public byte[] serialize(Object t)  {
        if (t == null) {
            return new byte[0];
        }
        return JsonSerialize.serialize(t);
    }

    @Override
    public Object deserialize(byte[] bytes)  {
        if (bytes == null || bytes.length == 0) {
            return null;
        }
        return JsonSerialize.unSerialize(bytes);
    }

}
